<template>
    <div class="sheet-list">
        <v-sheet :key="index" v-for="(label,index) in labelList" @click="toggle(label)" :elevation="2" class="sheet-item" border rounded>
            <span :style="{color:label.color}" class="label-level">{{ label.level }}</span>
            <span :style="{color:label.color,borderColor:label.color}" class="label-view">{{ label.name }}</span>
            <small>{{ label.remark }}</small>
        </v-sheet>
    </div>
    <div>
        <v-btn @click="toggle(null)" class="ma-2 btn_float" color="primary" icon="mdi-plus"></v-btn>
    </div>
    <label-edition :callback="reflesh" ref="EditionPanel"/>
</template>

<script>
import LabelEdition from '@/components/LabelEdition.vue'
// import { getUserInfo } from "@/api/auth.js";
import { labelList } from "@/api/label.js";
export default {
    name: 'LabelManagerView',
    components:{LabelEdition},
    data() {
        return {
            labelBo:{
                labelId:undefined,
                name:undefined,
                level:undefined,
                color:undefined,
                remark:undefined
            },
            labelList:[]
        }
    },
    created(){
        this.getList()
    },
    methods:{
        toggle(labelBo){
            this.$refs.EditionPanel.toggle(true,labelBo!=undefined?labelBo:null)
        },
        getList(){
            labelList(this.labelBo).then(resp=>{
                this.labelList=resp.data
                // console.log(resp);
            })
        },
        reflesh(){
            this.getList()
        }
    }
}
</script>

<style scoped>
.btn_float {
    position: fixed;
    right: 20px;
    bottom: 20px;
}
.label-view{
    border-style: solid;
    border-width: 1px;
    /* border: 1px solid red; */
    display: block;
    padding: 5px 10px;
    width: fit-content;
    font-size: 12px;
    /* color: #FFAFAF; */
    border-radius: 5px;
    margin-bottom: 10px;
}
.sheet-item{
    padding: 20px;
    margin-bottom: 20px;
}
.sheet-list{
    padding: 20px;
}
.label-level{
    float: right;
    font-size: 12px;
}
</style>